﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;
using System.Data;
using System.Net.Security;
using OpenComposite.Base.Collections;

namespace OpenComposite.HumanActivity.Contracts
{
	[ServiceContract(Namespace = "http://www.OpenComposite.com/internal")]
	public interface IHumanActivityDataService
	{
		/// <summary>
		/// User login.
		/// </summary>
		/// <param name="username">The username.</param>
		/// <param name="password">The password.</param>
		/// <param name="orgid">The orgid.</param>
		/// <param name="languageid">The languageid.</param>
		/// <param name="orgname">The orgname.</param>
		/// <returns></returns>
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		LogInData LogIn(string username, string password, int orgid, int languageid, string orgname, Guid applicationId);
		/// <summary>
		/// User logout.
		/// </summary>
		/// <param name="userdata">The userdata.</param>
		/// <returns></returns>
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		bool LogOut(LogInData userdata, Guid applicationId);

		/// <summary>
		/// Gets the activity inbox.
		/// </summary>
		/// <param name="userId">The user id.</param>
		/// <returns></returns>
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		List<ActivityItem> GetActivityInbox(int userId);
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		BindingListEx<ActivityItem> GetAdminActivityInbox(string processName, string activityName, DateTime createDateFrom, DateTime createDateTo, ActivityStatus[] status);
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		List<string> GetAdminProcessNames();
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		List<string> GetAdminActivityNames(string process);
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		string GetHumanActivityUrl(int activityId);

		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		List<Language> GetLanguages();
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		List<Country> GetCountries();
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		List<TimeZoneItem> GetTimeZones();

		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		UserPreferences GetUserPreferences(LogInData userdata);
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		bool SetUserPreferences(LogInData userdata, UserPreferences userpreferences);
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		PersonalUserData GetPersonalUserData(LogInData userdata);
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		bool SetPersonalUserData(LogInData userdata, PersonalUserData data);
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		bool UpdateUserPassword(LogInData userdata, string passwordOld, string passwordNew);

		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		List<Delegation> GetDelegations(LogInData userdata);
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		Delegation GetDelegation(string p, string p_2);
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		void SetDelegation(Delegation delegation);
		[OperationContract(), FaultContract(typeof(GenericFault), ProtectionLevel = ProtectionLevel.EncryptAndSign)]
		bool DeleteDelegation(Delegation delegation);
	}

	#region Class: Language
	[DataContract(Namespace = "http://www.OpenComposite.com/internal")]
	public class Language
	{
		[DataMember]
		public int LanguageID { get; set; }
		[DataMember]
		public string LanguageName { get; set; }
	}
	#endregion
	#region Class: Country
	[DataContract(Namespace = "http://www.OpenComposite.com/internal")]
	public class Country
	{
		[DataMember]
		public int LCID { get; set; }
		[DataMember]
		public string CountryName { get; set; }
	}
	#endregion
	#region Class: TimeZoneItem
	[DataContract(Namespace = "http://www.OpenComposite.com/internal")]
	public class TimeZoneItem
	{
		[DataMember]
		public string TimeZoneID { get; set; }
		[DataMember]
		public string TimeZoneName { get; set; }
	}
	#endregion
	#region Class: UserPreferences
	[DataContract(Namespace = "http://www.OpenComposite.com/internal")]
	public class UserPreferences
	{
		[DataMember]
		public bool EnableEMailActivity { get; set; }
		[DataMember]
		public string EMailAddress { get; set; }
		[DataMember]
		public int LanguageID { get; set; }
		[DataMember]
		public int LCID { get; set; }
		[DataMember]
		public string TimezoneId { get; set; }
	}
	#endregion
	#region Class: Delegation
	[DataContract(Namespace = "http://www.OpenComposite.com/internal")]
	public class Delegation
	{
		public Delegation()
		{
			this.DelegationID = null;
		}
		public Delegation(int delegationId)
		{
			this.DelegationID = delegationId;
		}

		[DataMember]
		public int? DelegationID { get; protected set; }
		[DataMember]
		public int UserID { get; set; }
		[DataMember]
		public int DelegateRoleID { get; set; }
		[DataMember]
		public int DelegateToUserID { get; set; }
		[DataMember]
		public DateTime DelegateStartDateTime { get; set; }
		[DataMember]
		public DateTime DelegateEndDateTime { get; set; }
	}
	#endregion
}
